// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import mainManage from "../../framework/mainManage";
import sceneMediator from "../../framework/sceneMediator";
import gameData from "../gameData";
import TTSDK from "../../framework/sdk/TTSDK";

const {ccclass, property} = cc._decorator;

@ccclass
export default class reliveView extends cc.Component {

    @property(cc.Node)
    roleNode : cc.Node = null;

    @property(cc.Node)
    petGroup : cc.Node = null;

    @property(cc.Node)
    videoPic : cc.Node = null;

    btnClick(event,data){
        if(parseInt(data) == 1){
            this.node.destroy();
            if(this.callback != null){
                this.callback();
            }
        }else if(parseInt(data) == 2){
            TTSDK.Instance.showRewardVideo({
                success:()=>{
                    gameData.isRelive = true;
                    sceneMediator.LoadCurScene();
                },
                fail :()=>{
                    mainManage.createToast("看完视频立即复活他吧!");
                }
            });
        }
    }

    callback = null;
    setCallBack(callback){
        this.callback = callback;
    }
}
